import {BasicColumn} from '@/components/Table';
import {BasicUpload, ImageUpload} from '@/components/Upload';
import {uploadImgApi} from "@/api/sys/upload";
import {h} from "vue";
import {Tag} from "ant-design-vue";



const cellContent = (_, index) => ({
  colSpan: index === 9 ? 0 : 1,
});

export function getMergeHeaderColumns(): BasicColumn[] {
  return [
    {
      title: 'ID',
      dataIndex: 'id',
      width: 300,
      customCell: (_, index) => ({
        colSpan: index === 9 ? 6 : 1,
      }),
    },
    {
      title: '姓名',
      dataIndex: 'name',
      width: 300,
      customCell: cellContent,
    },
    {
      title: '地址',
      dataIndex: 'address',
      colSpan: 2,
      width: 120,
      sorter: true,
      customCell: (_, index) => ({
        rowSpan: index === 2 ? 2 : 1,
        colSpan: index === 3 || index === 9 ? 0 : 1,
      }),
    },
    {
      title: '编号',
      dataIndex: 'no',
      colSpan: 0,
      filters: [
        { text: 'Male', value: 'male', children: [] },
        { text: 'Female', value: 'female', children: [] },
      ],
      customCell: cellContent,
    },
    {
      title: '开始时间',
      dataIndex: 'beginTime',
      width: 200,
      customCell: cellContent,
    },
    {
      title: '结束时间',
      dataIndex: 'endTime',
      width: 200,
      customCell: cellContent,
    },
  ];
}

export function getSkuListColumns(): BasicColumn[] {
  return [

    // {
    //   title: 'SKU编码',
    //   field: 'skuNumber',
    //   width: 120,
    // },
    {
      title: '成本价',
      field: 'costPrice',
      editRender: { name: 'VxeInput', props: { type: 'number' } },
      width: 120,
    },
    {
      title: '起售价',
      field: 'oriPrice',
      editRender: { name: 'VxeInput', props: { type: 'number' } },
      width: 150,
    },
    {
      title: '图片',
      field: 'skuPicValue',
      width: 180,
      slots: { default: 'img_default' },
      editComponentProps:{
        api: uploadImgApi,
        multiple: true,
        accept: ['.png', '.jpeg', '.jpg'],
        resultField: 'data.data',
        maxSize: '10',
        maxNumber: '30',
      }
    },
    {
      title: '库存',
      field: 'skuStocks',
      width: 80,

    },
    {
      title: '重量',
      field: 'weight',
      width: 120,
      editRender: { name: 'VxeInput', props: { type: 'number' } },
      // editComponentProps: {
      //   prefix: 'kg',
      // },
    },
    {
      title: '体积',
      field: 'volume',
      editRender: { name: 'VxeInput', props: { type: 'number' } },
      width: 120,
    },
    {
      title: '是否禁用',
      field: 'status',
      editRender: {
        name: 'select',
        options: [
          { label: '启用', value: 1 },
          { label: '禁用', value: 0 },
        ]
      },
      width: 80,

    }
  ];
}
